# -*- coding: latin-1 -*-

from Products.Archetypes.public import BaseSchema, BaseFolderSchema, Schema

from Products.Archetypes.public import StringField, StringWidget
from Products.Archetypes.public import SelectionWidget, MultiSelectionWidget
from Products.Archetypes.public import TextField, TextAreaWidget
from Products.Archetypes.public import LinesField, LinesWidget
from Products.Archetypes.public import BooleanField, BooleanWidget
#from Products.Archetypes.public import IntegerField, IntegerWidget
#from Products.Archetypes.public import DateTimeField, CalendarWidget
from Products.Archetypes.public import FileField, FileWidget
from Products.Archetypes.public import RichWidget, VisualWidget
from Products.Archetypes.public import ReferenceField, ReferenceWidget
from Products.Archetypes.public import DisplayList

from DIYWidget import DIYWidget
from Products.MasterSelectWidget.MasterSelectWidget import MasterSelectWidget

from Products.Archetypes.public import BaseContent, registerType, DisplayList
from Products.Archetypes.Marshall import RFC822Marshaller, PrimaryFieldMarshaller

# product
from iso_countries import iso_countries

DEFAULT_CONTENT_TYPE = 'text/html'

RESOURCETYPES = DisplayList((
    ('Catering', 'Catering'),     
    ('Chief Executive Office', 'Chief Executive Office'),
    ('Finance', 'Finance'),    
    ('Human Resources', 'Human Resources'),     
    ('Information', 'Information'),
    ('Legislation', 'Legislation'),
    ('Library', 'Library'),         
    ('Official Report (Hansard)', 'Official Report (Hansard)'),
    ('Parliamentary Commission', 'Parliamentary Commission'),
    ('Parliamentary Committee', 'Parliamentary Committee'),
    ('Procurement', 'Procurement'),
    ('Sergeant At Arms', 'Sergeant At Arms'),
    ('Speaker/Presidents Office', 'Speaker/Presidents Office'),
    ('Others', 'Others'),             
    ))

GENDER = DisplayList((
    ('Female', 'Female'),     
    ('Male', 'Male'),
    ))    

VIEWSTATUS = DisplayList((
    ('No', 'No'),    
    ('Yes', 'Yes'),
    ('Not applicable', 'Not applicable'),         
    ))    


OFFICIALLANGUAGES = DisplayList((
    ('Afrikaans', 'Afrikaans'),
    ('Amharic', 'Amharic'),
    ('Arabic', 'Arabic'),
    ('Creole', 'Creole'),
    ('English', 'English'),
    ('French', 'French'),
    ('Kirundi', 'Kirundi'),
    ('Kinyarwanda', 'Kinyarwanda'),
    ('Kiswahili', 'Kiswahili'),
    ('Ndebele', 'Ndebele'),
    ('Northern Sotho', 'Northern Sotho'),
    ('Portuguese', 'Portuguese'),
    ('Sesotho', 'Sesotho'),
    ('Somali', 'Somali'),
    ('Spanish', 'Spanish'),
    ('Swati', 'Swati'),
    ('Tsonga', 'Tsonga'),
    ('Tswana', 'Tswana'),
    ('Venda', 'Venda'),
    ('Xhosa', 'Xhosa'),
    ('Zulu', 'Zulu'),
    ))

REGIONS = {'Algeria': 'Northern Africa ',
           'Angola': 'Central Africa',
           'Benin': 'Western Africa',
           'Botswana': 'Southern Africa',
           'Burkina Faso': 'Western Africa',               
           'Burundi': 'Eastern Africa',
           'Kenya': 'Eastern Africa',
           'Lesotho': 'Southern Africa',
           'Cameroon': 'Central Africa',
           'Central African Republic': 'Central Africa',
           'Cape Verde': 'Western Africa',
           'Chad': 'Central Africa',
           'Comoros': 'Eastern Africa',               
           'Congo': 'Central Africa',
           'Cote DIvoire': 'Western Africa',
           'Democratic Republic of the Congo': 'Central Africa',
           'Djibouti': 'Eastern Africa',
           'Egypt': 'Northern Africa ',
           'Equatorial Guinea': 'Central Africa',               
           'Eritrea': 'Eastern Africa',
           'Ethiopia': 'Eastern Africa',
           'Gabon': 'Central Africa',
           'Gambia': 'Western Africa',
           'Ghana': 'Western Africa',
           'Guinea': 'Western Africa',               
           'Guinea-Bissau': 'Western Africa',
           'Kenya': 'Eastern Africa',
           'Lesotho': 'Southern Africa',
           'Liberia': 'Western Africa',
           'Libya': 'Northern Africa',
           'Madagascar': 'Southern AFrica',
           'Mali': 'Western Africa',               
           'Malawi': 'Eastern Africa',
           'Mauritius': 'Eastern Africa',
           'Mauritania': 'Western Africa',
           'Morocco': 'Northern Africa ',
           'Mozambique': 'Southern Africa',
           'Namibia': 'Eastern Africa',
           'Niger': 'Western Africa',               
           'Nigeria': 'Western Africa',
           'Reunion': 'Eastern AFrica',
           'Rwanda': 'Eastern Africa',
           'Sao Tome and Principe': 'Central Africa',
           'Senegal': 'Western Africa',
           'Seychelles': 'Eastern Africa',
           'Sierra Leone': 'Western Africa',
           'Somalia': 'Eastern Africa',               
           'South Africa': 'Southern Africa',
           'Sudan': 'Northern Africa ',
           'Swaziland': 'Southern Africa',
           'Tanzania': 'Eastern Africa',
           'Togo': 'Western Africa',
           'Tunisia': 'Northern Africa ',                              
           'Uganda': 'Eastern Africa',
           'Western Sahara': 'Northern Africa',
           'Zambia': 'Eastern Africa',
           'Zimbabwe': 'Eastern Africa',             
           }

ECONOMICBLOCS = {'Algeria': '',
                 'Angola': 'SADC',
                 'Benin': 'ECOWAS',
                 'Botswana': 'SADC',
                 'Burkina Faso': 'ECOWAS',               
                 'Burundi': 'EAC',
                 'Kenya': '',
                 'Lesotho': '',
                 'Cameroon': '',
                 'Central Africa Republic': '',
                 'Cape Verde': 'ECOWAS',
                 'Chad': '',
                 'Comoros': '',               
                 'Congo': '',
                 'Cote DIvoire': 'ECOWAS',
                 'Democratic Republic of the Congo': '',
                 'Djibouti': '',
                 'Egypt': 'COMESA',
                 'Equatorial Guinea': 'SADC',               
                 'Eritrea': '',
                 'Ethiopia': '',
                 'Gabon': '',
                 'Gambia': 'ECOWAS',
                 'Ghana': 'ECOWAS',
                 'Guinea': '',
                 'Guinea-Bissau': 'ECOWAS',
                 'Kenya': 'EAC',
                 'Lesotho': 'SADC',
                 'Liberia': 'ECOWAS',
                 'Libya': 'COMESA',
                 'Madagascar': 'SADC',
                 'Mali': 'ECOWAS',
                 'Malawi': 'SADC',
                 'Mauritius': 'SADC',
                 'Mauritania': 'ECOWAS',
                 'Morocco': '',
                 'Mozambique': 'SADC',
                 'Namibia': 'SADC',
                 'Niger': '',               
                 'Nigeria': 'ECOWAS',               
                 'Rwanda': 'EAC',
                 'Sao Tome and Principe': '',
                 'Senegal': 'ECOWAS',
                 'Seychelles': '',
                 'Sierra Leone': 'ECOWAS',
                 'Somalia': '',               
                 'South Africa': 'SADC',
                 'Sudan': 'IGAD',
                 'Swaziland': 'SADC',
                 'Tanzania': 'EAC, SADC',
                 'Togo': 'ECOWAS',
                 'Tunisia': '',
                 'Uganda': 'EAC',
                 'Western Sahara': '',
                 'Zambia': 'SADC',
                 'Zimbabwe': 'SADC',                   
           }

slave_fields = (
    # Controls the vocab of region
    {'name': 'region',
     'action': 'value',
     'vocab_method': 'getRegionVocab',
     'control_param': 'master',
    },
    {'name': 'economicbloc',
     'action': 'value',
     'vocab_method': 'getEconomicblocVocab',
     'control_param': 'master',
    },
)    


#####################################################################
## Person
#####################################################################


mxmContacts_person_schema = BaseSchema + Schema((

# Snailmail info

    StringField('title',
        widget = StringWidget(
            label = 'Shortname',
            label_msgid = 'label_shortname',
            description = 'How the person is usually addressed.',
            description_msgid = 'help_shortname_creation',
            i18n_domain = 'mxmcontacts',
        ),
#        accessor='Title',
#        required = 1,
        searchable = 1,
    ),

    StringField('gender',
        widget = SelectionWidget(
            format = 'select',
            label = 'Gender',
        ),
        searchable = 1,
        vocabulary = GENDER
    ),    

    StringField('firstname',
        widget = StringWidget(
            label = 'First Name',
            label_msgid = 'label_firstname',
            description = "Enter your first name.",
            description_msgid = 'help_firstname_creation',
            i18n_domain = 'mxmcontacts',
        ),
        searchable = 1,
    ),

    StringField('lastname',
        widget = StringWidget(
            label = 'Last Name',
            label_msgid = 'label_lastname',
            description = "Enter your last name.",
            description_msgid = 'help_lastname_creation',
            i18n_domain = 'mxmcontacts',
        ),
    ),

    StringField('jobtitle',
        widget = StringWidget(
            label = 'Job Title',
            label_msgid = 'label_jobtitle',
            description = "Enter your job title.",
            description_msgid = 'help_jobtitle_creation',
            i18n_domain = 'mxmcontacts',          
        ),
        searchable = 1,
    ),

    ReferenceField('department',
        widget = ReferenceWidget(
            checkbox_bound = 2,
            label = 'Department',
            label_msgid='label_department',
            description='Department',
            description_msgid='help_department_creation',
            i18n_domain='mxmcontacts',
        ),
        allowed_types=('mxmContactsResource',),
        vocabulary_custom_label='b.getObject().title_or_id() + "-" + b.getObject().country',
        relationship='department',
    ),

# E-info

    StringField('email',
        widget = StringWidget(
            label='E-mail',
            label_msgid='label_email_address',
            description='Enter your email address.',
            description_msgid='help_email_creation', 
            i18n_domain='mxmcontacts',
        ),
        validators=("isEmail",),
        searchable = 1,
    ),

    StringField('web',
        widget = StringWidget(
            label = 'Web address',
            label_msgid='label_web',
            description='Enter your web address.',
            description_msgid='help_web_creation', 
            i18n_domain='mxmcontacts',
        ),
        validators=("isUrl",),
        searchable = 1,
    ),

    StringField('country',
        widget = StringWidget(
            label = 'Country',
            label_msgid = 'label_country',
            description = 'Enter the country name',
            description_msgid = 'help_country_creation',
            i18n_domain = 'mxmcontacts',
        ),
        searchable = 1,
    ),    

    StringField('office_phone',
        widget = StringWidget(
            label = 'Office phone',
            label_msgid='label_office_phone',
            description='Enter your office phone.',
            description_msgid='help_office_phone_creation', 
            i18n_domain='mxmcontacts',
        ),
        searchable = 1,
    ),

    StringField('mobile_phone',
        widget = StringWidget(
            label = 'Mobile phone',
            label_msgid='label_mobile_phone',
            description='Enter your mobile phone.',
            description_msgid='help_mobile_phone_creation', 
            i18n_domain='mxmcontacts',
        ),
        searchable = 1,
    ),


    StringField('fax',
        widget = StringWidget(
            label = 'Fax',
            label_msgid='label_fax',
            description='Enter your fax.',
            description_msgid='help_fax_creation', 
            i18n_domain='mxmcontacts',
        ),
        searchable = 1,
    ),

# xtra

    TextField('body',
              searchable = 1,
              primary = 1,
              validators = ('isTidyHtmlWithCleanup',),
              default_content_type = DEFAULT_CONTENT_TYPE,
              default_output_type = 'text/html',
              allowable_content_types = ('text/structured',
                                         'text/restructured',
                                         'text/html',
                                         'text/plain',
                                         ),
              widget = RichWidget(
                        description = "The body text of the document.",
                        description_msgid = "help_body_text",
                        label = "Notes    ",
                        label_msgid = "label_notes_text",
                        rows = 25,
                        i18n_domain = "mxmcontacts")),
    ),
)



#####################################################################
## Organization
#####################################################################

mxmContacts_organization_schema = BaseSchema + Schema((

    StringField('title',
        widget = StringWidget(
            label = 'Parliament/Chamber',
            label_msgid='label_organization_name',
            description='Name of the parliament or chamber.',
            description_msgid='help_organization_creation', 
            i18n_domain='mxmcontacts',
        ),                   
        accessor='Title',
        required = 1,
        searchable = 1,
    ),


    StringField('presidenttitle',
        widget = StringWidget(
            label = 'Speaker/President',
            label_msgid='label_presidenttitle',
            description="Enter the speaker or President's designation.",
            description_msgid='help_president_creation', 
            i18n_domain='mxmcontacts',
        ),
        searchable = 1,
    ),


    StringField('presidentfirstname',
        widget = StringWidget(
            label = 'Speaker/President First Name',
            label_msgid='label_presidentfirstname',
            description="Enter the speaker or President's first name.",
            description_msgid='help_presidentfirstname_creation', 
            i18n_domain='mxmcontacts',
        ),
        searchable = 1,
    ),


    StringField('presidentlastname',
        widget = StringWidget(
            label = 'Speaker/President Last Name',
            label_msgid='label_presidentlastname',
            description="Enter the speaker or President's last name.",
            description_msgid='help_presidentlastname_creation', 
            i18n_domain='mxmcontacts',
        ),
        searchable = 1,
    ),                                                          
    

    StringField('relatedchamber',
        widget = StringWidget(
            label = 'Related Chamber',
            label_msgid='label_related_chamber',
            description='Enter the related chamber.',
            description_msgid='help_relatedchamber_creation', 
            i18n_domain='mxmcontacts',
        ),
        searchable = 1,
    ),

    StringField('officiallanguages',
        widget = MultiSelectionWidget(
            size = 5,
            format = 'select',
            label = 'Official Languages',
            label_msgid='label_officallanguages',
            description='Select the official languages.',
            description_msgid='help_officallanguages_creation', 
            i18n_domain='mxmcontacts',                    
        ),
        searchable = 1,
        vocabulary = OFFICIALLANGUAGES
    ),        

# snailmail info    

    TextField('address',
              searchable = 1,
              validators = ('isTidyHtmlWithCleanup',),
              default_content_type = DEFAULT_CONTENT_TYPE,
              default_output_type = 'text/html',
              allowable_content_types = ('text/structured',
                                         'text/restructured',
                                         'text/html',
                                         'text/plain',
                                         ),
              widget = RichWidget(
                        description = "The address of the parliament/chamber.",
                        description_msgid = "help_address_creation",
                        label = "Address",
                        label_msgid = "label_address",
                        rows = 5,
                        i18n_domain = "mxmcontacts")
    ),


    StringField('officiallanguages',
        widget = MultiSelectionWidget(
            size = 5,
            format = 'select',
            label = 'Official Languages',
            label_msgid='label_officallanguages',
            description='Select the official languages.',
            description_msgid='help_officallanguages_creation', 
            i18n_domain='mxmcontacts',                    
        ),
        searchable = 1,
        vocabulary = OFFICIALLANGUAGES
    ),


    StringField(
        name='country',
        searchable=1,
        default='',
          vocabulary=DisplayList(
              (('', 'Select a country.'),
               ('Algeria', 'Algeria'),
               ('Angola', 'Angola'),
               ('Benin', 'Benin'),
               ('Botswana', 'Botswana'),
               ('Burkina Faso', 'Burkina Faso'),               
               ('Burundi', 'Burundi'),
               ('Kenya', 'Kenya'),
               ('Lesotho', 'Lesotho'),
               ('Cameroon', 'Cameroon'),
               ('Central Africa Republic', 'Central Africa Republic'),
               ('Cape Verde', 'Cape Verde'),
               ('Chad', 'Chad'),
               ('Comoros', 'Comoros'),               
               ('Congo', 'Congo'),
               ("Cote DIvoire", "Cote D'Ivoire"),
               ('Democratic Republic of the Congo', 'Democratic Republic of the Congo'),
               ('Djibouti', 'Djibouti'),
               ('Egypt', 'Egypt'),
               ('Equatorial Guinea', 'Equatorial Guinea'),               
               ('Eritrea', 'Eritrea'),
               ('Ethiopia', 'Ethiopia'),
               ('Gabon', 'Gabon'),
               ('Gambia', 'Gambia'),
               ('Ghana', 'Ghana'),
               ('Guinea', 'Guinea'),               
               ('Guinea-Bissau', 'Guinea-Bissau'),
               ('Kenya', 'Kenya'),
               ('Lesotho', 'Lesotho'),
               ('Liberia', 'Liberia'),
               ('Libyan Arab Jamahiriya', 'Libyan Arab Jamahiriya'),
               ('Mali', 'Mali'),               
               ('Malawi', 'Malawi'),
               ('Mauritius', 'Mauritius'),
               ('Mauritania', 'Mauritania'),
               ('Morocco', 'Morocco'),
               ('Mozambique', 'Mozambique'),
               ('Namibia', 'Namibia'),
               ('Niger', 'Niger'),               
               ('Nigeria', 'Nigeria'),               
               ('Rwanda', 'Rwanda'),
               ('Sao Tome and Principe', 'Sao Tome and Principe'),
               ('Senegal', 'Senegal'),
               ('Seychelles', 'Seychelles'),
               ('Sierra Leone', 'Sierra Leone'),
               ('Somalia', 'Somalia'),               
               ('South Africa', 'South Africa'),
               ('Sudan', 'Sudan'),
               ('Swaziland', 'Swaziland'),
               ('Tanzania', 'Tanzania'),
               ('Togo', 'Togo'),
               ('Tunisia', 'Tunisia'),                              
               ('Uganda', 'Uganda'),
               ('Zambia', 'Zambia'),
               ('Zimbabwe', 'Zimbabwe'),               
              ),
          ),        
        widget=MasterSelectWidget(
            slave_fields=slave_fields,
            description="Country of the organization."
        ),
    ),

    StringField(
        name='region',
        searchable=1,
        default='',
        widget=StringWidget(
            description="Region - based on country.",
        ),
    ),


    StringField(
        name='economicbloc',
        searchable=1,
        default='',
        widget=StringWidget(
            description="Economic Bloc - based on country.",
        ),
    ),                                                      


    StringField('phone',
        widget = StringWidget(
            label = 'Phone',
            label_msgid='label_private_phone',
            description='Enter your phone.',
            description_msgid='help_phone_creation', 
            i18n_domain='mxmcontacts',
        ),
        searchable = 1,
    ),

    StringField('fax',
        widget = StringWidget(
            label = 'Fax',
            label_msgid='label_fax',
            description='Enter your fax.',
            description_msgid='help_fax_creation', 
            i18n_domain='mxmcontacts',
        ),
        searchable = 1,
    ),                                                      

# E-info

    StringField('email',
        widget = StringWidget(
            label='E-mail',
            label_msgid='label_email_address',
            description='Enter your email address.',
            description_msgid='help_email_creation', 
            i18n_domain='mxmcontacts',
        ),
        validators=("isEmail",),
        searchable = 1,
    ),


    StringField('web',
        widget = StringWidget(
            label = 'Web address',
            label_msgid='label_web',
            description='Enter your web address.',
            description_msgid='help_web_creation', 
            i18n_domain='mxmcontacts',
        ),
        validators=("isUrl",),
        searchable = 1,
    ),


    TextField('body',
              searchable = 1,
              primary = 1,
              validators = ('isTidyHtmlWithCleanup',),
              default_content_type = DEFAULT_CONTENT_TYPE,
             default_output_type = 'text/html',
              allowable_content_types = ('text/structured',
                                         'text/restructured',
                                         'text/html',
                                         'text/plain',
                                         ),
              widget = RichWidget(
                        description = "The body text of the document.",
                        description_msgid = "help_body_text",
                        label = "Body text",
                        label_msgid = "label_body_text",
                        rows = 25,
                        i18n_domain = "mxmcontacts")),
)
)



#####################################################################
## Resource
#####################################################################

mxmContacts_resource_schema = BaseSchema + Schema((

    StringField('title',
        widget = StringWidget(
            label = 'Department Name',
            label_msgid='label_resource',
            description='Name of the resource.',
            description_msgid='help_resource_creation',
            i18n_domain='mxmcontacts',
        ),
        accessor='Title',
        required = 1,
        searchable = 1,
    ),
    
    
    StringField('resourcetype',
        widget = SelectionWidget(
            format = 'select',
            label = 'Departments/Offices',
        ),
        searchable = 1,
        vocabulary = RESOURCETYPES
    ),

    ReferenceField('resource_owner',
        widget = ReferenceWidget(
            checkbox_bound = 2,
            label = 'Parliament/Chamber',
            label_msgid='label_owner_resource',
            description='Responsible/owner of the resource',
            description_msgid='help_owner_resource_creation',
            i18n_domain='mxmcontacts',
        ),
        searchable = 1,                  
        allowed_types=('mxmContactsOrganization',),
        vocabulary_custom_label='b.getObject().title_or_id() + "-" + b.getObject().country',
        relationship='resource_owner',
    ),

    StringField('viewstatus',
        widget = SelectionWidget(
            format = 'select',
            label = 'Open to the public',
        ),
        searchable = 1,
        vocabulary = VIEWSTATUS
    ),        


        StringField('head',
        widget = StringWidget(
            label = 'Head/Director',
            label_msgid='label_head',
            description='Enter the Head/Director of this department',
            description_msgid='help_head_creation', 
            i18n_domain='mxmcontacts',
        ),
        searchable = 1,
    ),                                                      

    TextField('address',
              searchable = 1,
              validators = ('isTidyHtmlWithCleanup',),
              default_content_type = DEFAULT_CONTENT_TYPE,
              default_output_type = 'text/html',
              allowable_content_types = ('text/structured',
                                         'text/restructured',
                                         'text/html',
                                         'text/plain',
                                         ),
              widget = RichWidget(
                        description = "The address of the parliament/chamber.",
                        description_msgid = "help_address_creation",
                        label = "Address",
                        label_msgid = "label_address",
                        rows = 5,
                        i18n_domain = "mxmcontacts")
    ),    
    
    StringField('country',
        widget = StringWidget(
            label = 'Country',
            label_msgid = 'label_country',
            description = 'Enter the country name',
            description_msgid = 'help_country_creation',
            i18n_domain = 'mxmcontacts',
        ),
        searchable = 1,
    ),

# E-info

    StringField('email',
        widget = StringWidget(
            label='E-mail',
            label_msgid='label_email_address',
            description='Enter your email address.',
            description_msgid='help_email_creation', 
            i18n_domain='mxmcontacts',
        ),
        validators=("isEmail",),
        searchable = 1,
    ),

    StringField('web',
        widget = StringWidget(
            label = 'Web address',
            label_msgid='label_web',
            description='Enter your web address.',
            description_msgid='help_web_creation', 
            i18n_domain='mxmcontacts',
        ),
        validators=("isUrl",),
        searchable = 1,
    ),

    StringField('phone',
        widget = StringWidget(
            label = 'Phone',
            label_msgid='label_private_phone',
            description='Enter your phone.',
            description_msgid='help_phone_creation', 
            i18n_domain='mxmcontacts',
        ),
        searchable = 1,
    ),

    StringField('fax',
        widget = StringWidget(
            label = 'Fax',
            label_msgid='label_fax',
            description='Enter your fax.',
            description_msgid='help_fax_creation', 
            i18n_domain='mxmcontacts',
        ),
        searchable = 1,
    ),

    TextField('body',
              searchable = 1,
              primary = 1,
              validators = ('isTidyHtmlWithCleanup',),
              default_content_type = DEFAULT_CONTENT_TYPE,
             default_output_type = 'text/html',
              allowable_content_types = ('text/structured',
                                         'text/restructured',
                                         'text/html',
                                         'text/plain',
                                         ),
              widget = RichWidget(
                        description = "The body text of the document.",
                        description_msgid = "help_body_text",
                        label = "Body text",
                        label_msgid = "label_body_text",
                        rows = 25,
                        i18n_domain = "mxmcontacts")),    
)
)



#####################################################################
## Group
#####################################################################

mxmContacts_group_schema = BaseSchema + Schema((

    StringField('title',
        widget = StringWidget(
            label = 'ContactGroup name',
            label_msgid='label_contact_group',
            description='Name of the ContactGroup.',
            description_msgid='help_contact_group_creation',
            i18n_domain='mxmcontacts',
        ),
        accessor='Title',
        required = 1,
        searchable = 1,
    ),

    TextField('description',
        widget = TextAreaWidget(
            label = 'Description',
            label_msgid='label_description_group',
            description='A short description of the content',
            description_msgid='help_description_group_creation',
            i18n_domain='mxmcontacts',
        ),
        accessor='Description',
        searchable = 1,
    ),

    TextField('text',
              searchable=True,
              validators = ('isTidyHtmlWithCleanup',),
              default_content_type = 'text/html',
              default_output_type = 'text/x-html-safe',
              widget = RichWidget(
                        description = "",
                        description_msgid = "help_body_text",
                        label = "Body Text",
                        label_msgid = "label_body_text",
                        rows = 25,
                        i18n_domain = "plone",
        )
    ),

    BooleanField('anonymousForm',
        widget = BooleanWidget(
            label = 'Anonymous form',
            label_msgid = 'label_anonymousForm',
            description = "Let anonymous add their contact info.",
            description_msgid = 'help_anonymousForm',
            i18n_domain = 'mxmcontacts',
        ),
        default=False,
    ),

    BooleanField('showMembersList',
        widget = BooleanWidget(
            label = 'Show member list',
            label_msgid = 'label_showMembersList',
            description = "Show the members list on the frontpage.",
            description_msgid = 'help_showMembersList',
            i18n_domain = 'mxmcontacts',
        ),
        default=True,
    ),

    BooleanField('anonymousUnsubscribe',
        widget = BooleanWidget(
            label = 'Unsubscribe by URL',
            label_msgid = 'label_anonymousUnsubscribe',
            description = "Allow 'anonymous' users to unsubscribe their contact info via an URL.",
            description_msgid = 'help_anonymousUnsubscribe',
            i18n_domain = 'mxmcontacts',
        ),
        default = False,
    ),

    ), marshall=RFC822Marshaller()

)


# the possibility to add custom schemas for contacts
try:
    import schemasCustom
    if hasattr(schemasCustom, 'mxmContacts_person_schema') and \
                        schemasCustom.mxmContacts_person_schema:
        mxmContacts_person_schema = mxmContacts_person_schema + \
                          schemasCustom.mxmContacts_person_schema
                                    
    if hasattr(schemasCustom, 'mxmContacts_organization_schema') and \
                        schemasCustom.mxmContacts_organization_schema:
        mxmContacts_organization_schema = mxmContacts_organization_schema + \
                                schemasCustom.mxmContacts_organization_schema
    
    if hasattr(schemasCustom, 'mxmContacts_organization_schema') and \
                        schemasCustom.mxmContacts_organization_schema:
        mxmContacts_organization_schema = mxmContacts_organization_schema + \
                                schemasCustom.mxmContacts_organization_schema
    
    if hasattr(schemasCustom, 'mxmContacts_group_schema') and \
                        schemasCustom.mxmContacts_group_schema:
        mxmContacts_group_schema = mxmContacts_group_schema + \
                         schemasCustom.mxmContacts_group_schema
except ImportError:
    pass

